<!-- 我的评价 -->
<template>
  <view class="evaluation">
	  <template v-for="(item,i) in list">
	  	<view class="content" :key="item.id" v-if="list.length>0" @click="detail(i)">
	  	  <view class="left">
			  <image
	  	      :src="userInfo.userInfo.avatar"
	  	      mode="">
			  </image>
			</view>
	  	  <view class="right">
	  	    <view class="name">{{userInfo.userInfo.username}}</view>
	  	    <view class="user_evaluation">
				{{item.content}}
			</view>
	  	    <view class="img">
	  	      <!-- <image
	  	        src="https://community.chuangxiangdianli.com/images/neighborimg/z_tr@2x.png"
	  	        mode=""
	  	      ></image>
	  	      <image
	  	        src="https://community.chuangxiangdianli.com/images/neighborimg/z_tr@2x.png"
	  	        mode=""
	  	      ></image> -->
	  	    </view>
	  	    <view class="time">{{item.created_at}}</view>
	  	    <view class="goods">
	  	      <view class="goods_img" v-if="item.goods">
				  <image
					  v-if="item.goods.goods_images.length>0"
					  :src="item.goods.goods_images[0]"
					  mode="">
				</image
	  	      ></view>
	  	      <view class="goods_info">
	  	        <view class="goods_name">{{item.goods.goods_name}}</view>
	  	        <view class="price">￥ {{item.goods.goods_price}}</view>
	  	      </view>
	  	    </view>
	  	  </view>
	  	</view>
	</template>
		<u-loadmore :status="status" />
  </view>
</template>

<script>
	// 引入封装的请求
	import request from '@/utils/request.js'
export default {
  data() {
    return {
		// 用户信息
		userInfo:{},
		// 闲置列表
		list:[],
		// 当前页码
		pageNo:1,
		// 当前的数据条数
		limit:10,
		// 是否正在请求数据
		is_loading:false,
		// 是否请求完数据
		is_bottom:false,
		// 底部正在加载中
		status: 'loadmore',
	};
  },
  onLoad() {
  	this.get_message_list()
  },
  onShow() {
	  let that = this
  	uni.getStorage({
  		key:'userInfo',
  		success:function(res){
  			// console.log(res)
  			that.userInfo = res.data
  		},
  		fail:function(res){
  			uni.navigateTo({
  				url: '/login/bindinguser/index'
  			})
  		},
  	})
  },
  // 页面底部加载
  onReachBottom(){
  	let that = this
  	this.status = 'loading';
  	// console.log(11111)
  	if(that.status = 'nomore' || that.is_loading){
  		return false
  	}
  	this.pageNo++
  	setTimeout(() => {
  		that.get_message_list(true)
  	}, 1000)
  },
  methods:{
	  // 订单详情
	  detail(i){
		  let id = this.list[i].order_id
		  uni.navigateTo({
		  	url:'../../order/orderDetail?id='+id+'&type=1'
		  })
	  },
	  // 获取评论列表
	  get_message_list(turn){
	  	let that = this
	  	that.is_loading = true
	  	request.get('Mini/circle/flea/getMyComment',{
	  		page:that.pageNo,
	  		pre_page:that.limit
	  	}).then(res => {
	  		// console.log('首页数据', res)
	  		that.is_loading = false
	  		if (res.code==200) {
	  			if(turn){
	  				if(res.data.data.length>0){
	  					that.list = [
	  						...that.list,
	  						...res.data.data
	  					]
	  				}
	  			}else{
	  				that.list = res.data.data
	  			}
	  			
	  			if(res.data.count==that.list.length){
	  				// that.is_boottom = true
	  				that.status = 'nomore';
	  			}
	  		} else {
	  			uni.showToast({
	  				title: res.msg,
	  				icon: 'none'
	  			})
	  		}
	  	}).catch(res => {
	  		uni.showToast({
	  			title: res.msg,
	  			icon: 'none'
	  		})
	  	})
	  }
  }
};
</script>

<style lang="scss">
.evaluation {
  margin-bottom: 30rpx;
  .content {
    width: 100%;
    min-height: 506rpx;
    padding: 20rpx;
    box-sizing: border-box;
    background: #ffffff;
    display: flex;
    align-items: top;
    justify-content: flex-start;
    .left {
      width: 15%;
      image {
        width: 68rpx;
        height: 68rpx;
        margin-left: 10rpx;
		border-radius: 50%;
      }
    }
    .right {
      width: 85%;
      border-bottom: 2rpx solid #dcdcdc;
      padding-bottom: 26rpx;
      .name {
        font-size: 30rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #999999;
        margin-bottom: 30rpx;
      }
      .user_evaluation {
        font-size: 30rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #333333;
        margin-bottom: 20rpx;
      }
      .img {
        image {
          display: inline-block;
          width: 100rpx;
          height: 100rpx;
          margin-right: 28rpx;
        }
        margin-bottom: 18rpx;
      }
      .time {
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #999999;
        margin-bottom: 40rpx;
      }
      .goods {
        width: 100%;
        display: flex;
        align-items: top;
        justify-content: flex-start;
        .goods_img {
          width: 20%;
          image {
            width: 100rpx;
            height: 100rpx;
            border-radius: 5rpx;
          }
        }
        .goods_info {
          width: 80%;
          .goods_name {
			  max-width: 480rpx;
			  overflow: hidden;
			  text-overflow: ellipsis;
			  white-space: nowrap;
            font-size: 26rpx;
            font-family: Hiragino Sans GB;
            font-weight: normal;
            color: #333333;
            margin-bottom: 20rpx;
          }
          .price {
            font-size: 30rpx;
            font-family: Hiragino Sans GB;
            font-weight: bold;
            color: #b83d42;
          }
        }
      }
    }
  }
}
</style>
